'''使用tkinter创建一个图形界面，并绘制一个由红色线条组成的螺旋图案

from tkinter import *

canvas = Canvas(width=300, height=300, bg='white')
canvas.pack(expand=True, fill=BOTH)

x0, y0 = 163, 163
y1 = 175
for i in range(0,20):
  canvas.create_line(x0, y0, x0,y1, width=1, fill='red')
  x0, y0 = x0 -5, y0-5
  y1 = y1 + 5

x0, y0 = 163, 163
y1 = 175
for i in range(0,20):
  canvas.create_line(x0, y0, x0,y1, width=1, fill='red')
  x0, y0 = x0 + 5 , y0 + 5
  y1 = y1 + 5

root = Tk()
root.mainloop()
'''
from unicodedata import digit

'''
使用tkinter描绘一个螺旋的矩形

from tkinter import *

canvas = Canvas(width=300, height=300, bg='white')
canvas.pack(expand=True, fill=BOTH)

x0, y0 = 50,50
x1, y1 = 200,200
for i in range(0,30):
    canvas.create_rectangle(x0, y0, x1,y1, width=1)
    x0, y0 = x0 + 5, y0 + 5
    x1, y1 = x1 - 5, y1 - 5

root = Tk()
root.mainloop()
'''

'''
编写一个程序，使用random模块生成随机数

import random

# random.random()#生成一个介于0.0到1.0不包含1.0 之间的随机小数
# random_number = random.random()
# print(f"{random_number:.2f}")

# random.randint(a,b)生成一个介于a和b之间的随机整数
# print(random.randint(0,6))

# random.choice(sequence)从给定的序列中随机选择一个元素
# lst1 = ["石头","剪刀","布"]
# random_element = random.choice(lst1)
# print(random_element)

# random.shuffle([1,2,3,4,5,6,7,8,9])给列表中元素进行随机排序，直接改变列表
'''

'''
程序可以根据用户指定长度生成一个验证码


import random
import string

x = int(input("请输入验证码长度："))
lst1 = string.ascii_letters + string.digits  # 包含大小写字母和数字
code = ''.join(random.choice(lst1) for _ in range(x))
print(f"验证码是：{code}")
'''

'''
程序能够从用户指定的数字范围中随机选择3个不重复的数字


import random
import string
x = int(input("请输入数字1："))
y = int(input("请输入数字2："))
lst1 = list(range(x, y+1))

for i in range(3):
    if not lst1:
        break
    lst1.append(i)
    num = random.choice(lst1)
    print(num)
    lst1.remove(num)
    '''

